<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<%@ page contentType="text/html; charset=utf-8"%>
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>平台管理系统</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <link rel="stylesheet" href="/layuiadmin/layui/css/layui.css" media="all">
    <link rel="stylesheet" href="/layuiadmin/style/admin.css" media="all">
    <link rel="stylesheet" href="/layuiadmin/style/template.css" media="all">
    <link rel="stylesheet" href="/css/bus-style.css" media="all">
    <style>
        span{line-height: 30px}
    </style>
</head>
<body>
<div class="layui-fluid layadmin-maillist-fluid">
    <div class="layui-row layui-col-space15">
        <div class="test-table-reload-btn layui-col-sm-offset1">
            <button class="layui-btn addThis" data-type="addThis" type="button" data-id="">新建运费模板</button>
        </div>
        <div class="layui-col-md12" style="height: 120%;background: #fff">
            <c:forEach items="${expList}" var="l">
                <div class="layui-col-md8 layui-col-md-offset1" style="margin-bottom: 20px;margin-top: 20px;">
                    <div class="layadmin-contact-box" style="border-radius: 5px">
                        <div class="layui-col-md10 layadmin-padding-left20 layui-col-sm8">
                            <span style="font-size: 18px">模板名称：${l.name}</span>
                            <div class="layui-col-sm12" style="margin-bottom: 5px">
                                <p>
                                    <span style="font-weight: bold">包邮规则：</span>
                                    <span class="orange">订单金额满足：<span>${l.money}</span>包邮</span>
                                    或者 <span class="orange">购买重量/数量满足：${l.vals} 包邮</span>
                                </p>
                            </div>
                            <c:forEach items="${l.expDetailList}" var="s">
                            <div class="layui-col-sm12 " style="margin-bottom: 10px;">
                                <p>
                                    <span style="font-weight: bold">${s.addressStr==null?'默认运费':s.addressStr}</span>
                                    <span class="red">${s.beginNum}</span><span> 件内</span>
                                    <span class="red">${s.beginMoney}</span><span> 元，每增加 </span>
                                    <span class="red">${s.addNum}</span><span> 件，运费增加 </span>
                                    <span class="red">${s.addMoney}</span><span> 元</span><br>
                                </p>
                            </div>
                               <br/>
                            </c:forEach>
                        </div>
                        <hr>
                        <div class="layui-col-md10 layadmin-padding-left20 layui-col-sm8" style="margin-top: 10px">
                            <button data-id="${l.id}" data-type="editThis" type="button" class="layui-btn layui-btn-warm editThis">编辑</button>
                            <button data-id="${l.id}" data-type="delThis" type="button" class="layui-btn layui-btn-danger delThis">删除</button>
                        </div>
                    </div>
                </div>
            </c:forEach>
        </div>
    </div>
</div>

<script src="/layuiadmin/layui/layui.js"></script>
<script type="text/javascript" src="/js/jquery/jquery.min.js"></script>
<script type="text/javascript" src="/js/common.js"></script>
<script>
    layui.config({
        base: '/layuiadmin/' //静态资源所在路径
    }).extend({
        index: 'lib/index' //主入口模块
    }).use(['index', 'form'], function(){
        var $ = layui.$,
            form = layui.form,
            element = layui.element,
            layer = layui.layer;
        element.render();
        form.render();

        var active = {
            addThis: function () {
                window.location.href = "/exp/expModelAdd";
            },
            editThis: function (id) {
                window.location.href = "/exp/expModelEdit?id="+id;
            },
            delThis:function (id,url,msg) {
                layer.confirm(msg, function(){
                    delThis(id,url);
                });
            }
        };
        $('.addThis').on('click', function(){
            var type = $(this).data('type');
            active[type] && active[type].call(this);
        });
        $('.editThis').on('click', function(){
            var type = 'editThis';
            var id = $(this).data('id');
            active[type] && active[type].call(this,id);
        });
        $('.delThis').on('click',function () {
            var delType = $(this).data('type');
            var id = $(this).data('id');
            var url = "/exp/deleteExpModel";
            var msg = '确定删除吗？<br>删除运费模板将会<span style="color:red;font-weight:bold;">下架关联该模板的商品</span>！';
            active[delType] && active[delType].call(this,id,url,msg);
        });
    });
</script>
</body>
</html>